home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / audio / midi / parse.c++ < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.4 KB  |  64 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include "parse.h"
  18.  
  19. extern "C" { bzero(void *, int); }
  20.  
  21.     
  22. miParser::miParser()
  23. {
  24.     bzero(this, sizeof(this));
  25. }
  26.  
  27. static int getidx(int stat)
  28. {
  29.     int idx = stat >> 4;
  30.     if (stat > 0xf0) idx += stat & 0xf;
  31.     return idx;
  32. }
  33.  
  34. void 
  35. miParser::changeCallBack(MIDIstatus stat, miCallBack func, void *arg, int size)
  36. {
  37.     int idx = getidx(stat);
  38.     
  39.     table[idx].fun = func;
  40.     table[idx].arg = arg;
  41.     table[idx].size = size;
  42. }
  43.  
  44. void 
  45. miParser::Parse(MIevent ev)
  46. {
  47.     int idx;
  48.     
  49.     if (ev.t != MISYSEX)
  50.     idx = getidx(ev.mm.msgbuf.status());
  51.     else 
  52.     idx = 0xf;
  53.  
  54.     struct funarg f = table[idx];
  55.     
  56.     if (!f.fun) return;
  57.  
  58.     if (f.fun)
  59.     (f.fun)(ev, f.arg, f.size);
  60. }
  61.  
  62.     
  63.     
  64.